package com.bicycle.rentalsystem.service.impl.user;

import com.bicycle.rentalsystem.dao.UserDao;

import com.bicycle.rentalsystem.dao.impl.user.UserDaoImpl;
import com.bicycle.rentalsystem.pojo.user.User;
import com.bicycle.rentalsystem.service.UserService;

/**
 * 用户业务层实现类
 * 处理权限和登录
 * 目前不需要更改
 */

public class UserServiceImpl implements UserService {

    private UserDao userDao = new UserDaoImpl();

    //登录判断
    @Override
    public int login(String username, String password) {
        User user = userDao.getUserByUsername(username);
        if (user == null) return -1;
        return password.equals(user.getPassword()) ? 1 : 0;
    }
    //权限判断
    @Override
    public Integer getIdentity(String username) {
        return userDao.getIdentity(username);
    }

    @Override
    public User getUserByUsername(String username) {
        return userDao.getUserByUsername(username);
    }


}

